//
//  FSSpecialModel.m
//  fanshu
//
//  Created by mh on 16/3/28.
//  Copyright © 2016年 FS. All rights reserved.
//

#import "FSDiscoverSpecialModel.h"

@implementation FSDiscoverSpecialModel

- (CGFloat)cellHeight{
    if (_cellHeight == 0) {
        //专题图标
        CGFloat margin = 10;
        CGFloat iconViewWH = 40;
        CGFloat iconViewX = margin;
        CGFloat iconViewY = margin;
        self.iconViewF = CGRectMake(iconViewX, iconViewY, iconViewWH, iconViewWH);
        //专题名称
        CGFloat specialX = CGRectGetMaxX(self.iconViewF) + margin;
        CGFloat specialY = iconViewY + margin * 0.5;
        CGSize specialSize = [self.special sizeWithFont:specialFont];
        self.specialF = (CGRect){{specialX,specialY},specialSize};
        
        //多出来的几个文字的宽度
        CGFloat paddingWidth = [[NSString stringWithFormat:@"篇文章"] sizeWithFont:countOfArticleFont].width;
        //发布文章总数
        CGFloat countOfArticleX = specialX;
        CGFloat countOfArticleY = CGRectGetMaxY(self.specialF) + margin * 0.3;
        CGSize countOfArticleSize = [self.countOfArticle sizeWithFont:countOfArticleFont];
        CGFloat countOfArticleW = countOfArticleSize.width + paddingWidth;
        CGFloat countOfArticleH = countOfArticleSize.height;
        self.countOfArticleF = CGRectMake(countOfArticleX, countOfArticleY, countOfArticleW, countOfArticleH);
        //关注人数
        CGFloat countOfAttentedFX = CGRectGetMaxX(self.countOfArticleF) + margin * 0.5;
        CGFloat countOfAttentedFY = countOfArticleY;
        CGFloat countOfAttentedFW = [self.countOfAttented sizeWithFont:countOfAttentedFont].width + paddingWidth;
        CGFloat countOfAttentedFH = countOfArticleH;
        self.countOfAttentedF = CGRectMake(countOfAttentedFX, countOfAttentedFY, countOfAttentedFW, countOfAttentedFH);
        //关注按钮
        CGFloat attentedX = iconViewX;
        CGFloat attentedY = CGRectGetMaxY(self.iconViewF) + margin * 0.5;
        CGFloat attentedW = iconViewWH;
        CGFloat attentedH = [[NSString stringWithFormat:@"关注"] sizeWithFont:specialFont].height;
        self.attentedBtnF = CGRectMake(attentedX, attentedY, attentedW, attentedH);
        //专题介绍
        CGFloat introductionX = countOfArticleX;
        CGFloat introductionY = CGRectGetMaxY(self.countOfArticleF) + margin;
        CGFloat introductionW = ScreenWidth - introductionX - margin;
        CGFloat introductionH = [self.introduction sizeWithFont:introductionFont maxW:introductionW].height;
        if (introductionH > 60) introductionH = 60;
        self.introductionF = CGRectMake(introductionX, introductionY, introductionW, introductionH);
        
        _cellHeight = CGRectGetMaxY(self.introductionF) + margin * 1.5;
    }
    return _cellHeight;
}

@end
